package Control;
import java.util.*;


public class Episode {
	private int numEpisode;
	private Season season;
	private String name;
	private HashMap<Character, Integer> numLines;
	private HashMap<Character, ArrayList<String>> lines;
	private ArrayList<Character> newCharacters;
	private HashMap<CatchPhrase, Integer> numCatchphrases; 
	
	public Episode() {
		super();
		numLines = new HashMap<Character, Integer>();
		lines = new HashMap<Character, ArrayList<String>>();
		newCharacters = new ArrayList<Character>();
		numCatchphrases = new HashMap<CatchPhrase, Integer>();
	}

	public Episode(int numEpisode, Season season, String name,
			HashMap<Character, Integer> numLines,
			HashMap<Character, ArrayList<String>> lines,
			ArrayList<Character> newCharacters) {
		super();
		this.numEpisode = numEpisode;
		this.season = season;
		this.name = name;
		this.numLines = numLines;
		this.lines = lines;
		this.newCharacters = newCharacters;
	}

	public int getNumEpisode() {
		return numEpisode;
	}

	public void setNumEpisode(int numEpisode) {
		this.numEpisode = numEpisode;
	}

	public Season getSeason() {
		return season;
	}

	public void setSeason(Season season) {
		this.season = season;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}
	
	public HashMap<Character, Integer> getNumLines() {
		return numLines;
	}

	public void setNumLines(HashMap<Character, Integer> numLines) {
		this.numLines = numLines;
	}

	public HashMap<Character, ArrayList<String>> getLines() {
		return lines;
	}

	public void setLines(HashMap<Character, ArrayList<String>> lines) {
		this.lines = lines;
	}

	public ArrayList<Character> getNewCharacters() {
		return newCharacters;
	}

	public void setNewCharacters(ArrayList<Character> newCharacters) {
		this.newCharacters = newCharacters;
	}
	
	public HashMap<CatchPhrase, Integer> getNumCatchphrases() {
		return numCatchphrases;
	}

	public void setNumCatchphrases(HashMap<CatchPhrase, Integer> numCatchphrases) {
		this.numCatchphrases = numCatchphrases;
	}

	

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + numEpisode;
		result = prime * result + ((season == null) ? 0 : season.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Episode other = (Episode) obj;
		if (numEpisode != other.numEpisode)
			return false;
		if (season == null) {
			if (other.season != null)
				return false;
		} else if (!season.equals(other.season))
			return false;
		return true;
	}

	@Override
	public String toString() {
		return "S" + season.getNumber() +" E" + numEpisode + 
				 " " + name ;
	}
	
	
	public static int returnIndex(List<Episode> list, Episode ep){
		for(int i = 0; i < list.size(); i++)
			if(list.get(i).equals(ep))
				return i;
		return -1;
	}
	
}
